import 'dart:collection';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterappmydemo/utils/image_helper.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:shimmer/shimmer.dart';
import 'package:toast/toast.dart';
//import 'package:fluttertoast/fluttertoast.dart';

class BasisExample extends StatelessWidget {
  var goodsId = "0";

  BasisExample(this.goodsId, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print('BasisExample.build goodsId= $goodsId');

    const mList1 = [1, 2, 3, 4]; //不可变的列表
    var mList2 = [1, 23, 4, 5]; //可变的列表

    var mList3 = new List<String>();
    mList3.add("1");
    mList3.add("2");
    mList3.add("3");

    print('BasisExample.build mList= $mList3');

    var s1 = '''dfksa;lskdfk dfksa;lskdfk dfksa;lskdfk dfksa;lskd
    fk''';

    print('BasisExample.build s1= $s1');

    Map<String, dynamic> mMap = HashMap();
    mMap['name'] = "ypk";

    String a = null;
    String b = "22";

    if (a == b) {
      print('BasisExample.build a == b');
    }

    if (a != null && a.isNotEmpty) {
      print('BasisExample.build a is not null');
    } else {
      print('BasisExample.build a is  null');
    }

    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.red),
      home: Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () {
              Navigator.pop(context, '我来自 BasisExample 界面');
            },
          ),
          title: Text('基础'),
          centerTitle: true,
        ),
        body: (Scrollbar(
          child: SingleChildScrollView(
            scrollDirection: Axis.vertical,
            //reverse: false,
            padding: EdgeInsets.all(10.0),
            child: Column(
              children: <Widget>[
                /* Image.asset(
                  "assets/images/1.jpeg",
                  fit: BoxFit.cover,
                  width: 50, //MediaQuery.of(context).size.width,
                  height: 50, // MediaQuery.of(context).size.height,
                ),*/

                ImageHelper.loadAssetsImagePNG(
                  'ic_zan_orange_fill',
                  width: 50,
                  height: 50,
                ),

                ///
                Align(
                  alignment: FractionalOffset.centerLeft,
                  // alignment: FractionalOffset(0.0, 0.5),
                  child: Text(
                    'Align左对齐(推荐) Android模拟器网络连接问题解决[转]',
                    textAlign: TextAlign.left,
                    softWrap: true,
                  ),
                ),
                Container(
                  alignment: AlignmentDirectional.centerStart,
                  child: Text(
                    'Container左对齐 Android模拟器网络连接问题解决[转]',
                    textAlign: TextAlign.left,
                    softWrap: true,
                  ),
                ),

                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      'Row左对齐 Android模拟器网络连接问题解决[转]',
                      textAlign: TextAlign.left,
                      softWrap: true,
                    ),
                  ],
                ),

                ///
                Shimmer.fromColors(
                  baseColor: Colors.red,
                  highlightColor: Colors.yellow,
                  child: Container(
                    alignment: AlignmentDirectional.centerStart,
                    child: Text(
                      'Container左对齐 Android模拟器网络连接问题解决[转]',
                      textAlign: TextAlign.left,
                      softWrap: true,
                    ),
                  ),
                ),

                ///
                SizedBox(
                  width: 200.0,
                  height: 100.0,
                  child: Shimmer.fromColors(
                    baseColor: Colors.red,
                    highlightColor: Colors.yellow,
                    child: Text(
                      'Shimmer',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 40.0,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                ),

                ///
                Container(
                  margin: EdgeInsets.all(15.0),
                  width: double.infinity,
                  height: 200,
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: new Border.all(
                      color: Colors.grey,
                      width: 8.0,
                    ),
                    borderRadius:
                        const BorderRadius.all(const Radius.circular(8.0)),
                  ),
                  child: Text(
                    'Flutter',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        fontSize: 28.0,
                        color: Colors.amber,
                        //删除线
                        decoration: TextDecoration.lineThrough),
                  ),
                ),
                Container(
                  margin:
                      EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0),
                  width: double.infinity,
                  child: RaisedButton(
                    textColor: Colors.white,
                    color: Colors.red,
                    child: Text('RaisedButton'),
                    elevation: 5,
                    onPressed: () {
                      //Toast.show("点击了RaisedButton按钮", context);
                      Fluttertoast.showToast(msg: "点击了RaisedButton按钮");
                    },
                  ),
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: <Widget>[
                    Text('文本控件'),
                    RaisedButton(
                      textColor: Colors.white,
                      color: Colors.red,
                      child: Text('RaisedButton'),
                      onPressed: () {},
                    ),
                    FlatButton(
                      textColor: Colors.white,
                      color: Colors.red,
                      child: Text('FlatButton'),
                      onPressed: () {
                        print('点击了按钮');
                      },
                    ),
                  ],
                ),
                OutlineButton(
                  textColor: Colors.blue,
                  child: Text('OutlineButton'),
                  onPressed: () {
                    // Fluttertoast.showToast(msg: "点击了OutlineButton按钮",gravity: ToastGravity.CENTER);
                  },
                ),

                ///
                Center(
                  child: Container(
                    width: 300,
                    height: 300,
                    padding: EdgeInsets.all(60.0),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      border: Border.all(
                        color: Colors.green,
                        width: 8.0,
                      ),
                    ),
                    child: Container(
                      width: 200,
                      height: 200,
                      decoration: BoxDecoration(
                        color: Colors.white,
                        border: Border.all(
                          color: Colors.blue,
                          width: 8.0,
                        ),
                      ),
                      child: FlutterLogo(),
                    ),
                  ),
                ),

                ///
                GestureDetector(
                  onTap: () {
                    /* final snackBar=new SnackBar(content: new Text('你已按下'),);
                    Scaffold.of(context).showSnackBar(snackBar);*/
                    Fluttertoast.showToast(msg: "你已按下");
                  },
                  child: Container(
                      padding: EdgeInsets.all(10.0),
                      margin: EdgeInsets.symmetric(
                          horizontal: 15.0, vertical: 20.0),
                      decoration: BoxDecoration(
                        color: Theme.of(context).buttonColor,
                        borderRadius: BorderRadius.circular(10.0),
                      ),
                      width: double.infinity,
                      child: Text(
                        "手势检测",
                        textAlign: TextAlign.center,
                      )),
                ),

                ///
              ],
            ),
          ),
        )),
      ),
    );
  }
}
